<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::group([
    'prefix' => 'v1',
    'middleware' => ['api', 'throttle:1000']
], function () {
    Route::post("/getUserInfo", "Api\UserDataController@getUserInfo");

    Route::post("/getIndexData", "Api\OthersController@getIndexData");
    Route::post("/getIndexInformations", "Api\OthersController@getIndexInformations");
    Route::post("/getIndexComments", "Api\OthersController@getIndexComments");

    Route::post("/register", "Api\RegisterController@register");
    Route::post("/getBackPassword", "Api\RegisterController@getBackPassword");
    Route::post("/getRegisterSms", "Api\RegisterController@sendSms")->middleware("App\Http\Middleware\CaptchaCheck");
    Route::post("/getGetBackSms", "Api\RegisterController@sendGetBackSms")->middleware("App\Http\Middleware\CaptchaCheck");
    Route::post("/login", "Api\LoginController@login");
    Route::post("/logout", "Api\LoginController@logout")->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");

    Route::post("/bankCards", "Api\UserDataController@bankCards");
    Route::post("/getBankCard", "Api\UserDataController@getBankCard");
    Route::post("/createBankCard", "Api\UserDataController@storeBankCard");
    Route::post("/updateBankCard", "Api\UserDataController@updateBankCard");
    Route::post("/deleteBankCard", "Api\UserDataController@deleteBankCard");
    Route::post("/updatePhone", "Api\UserDataController@updatePhone");
    Route::post("/updatePassword", "Api\UserDataController@updatePassword");
    Route::post("/getBackWithdrawPassword", "Api\UserDataController@getBackWithdrawPassword");
    Route::post("/getSms", "Api\UserDataController@sendSms")->middleware("App\Http\Middleware\CaptchaCheck");
    Route::post("/updateNickname", "Api\UserDataController@updateNickname");
    Route::post("/createCertification", "Api\UserDataController@storeCetification");
    Route::post("/uploadAvatar", "Api\UserDataController@uploadAvatar");

    //充值
    Route::post("/offlineTransfer", "Api\RechargeController@offlineTransfer")->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::get("/netPayment", "Api\RechargeController@netPayment");
    Route::get("/quickPayment", "Api\RechargeController@quickPayment");
    Route::any("/rechargeNotify", "Api\RechargeController@notify");

    //图片二维码
    Route::post("/createCaptcha", "Api\CaptchaController@generateCaptcha");
    Route::post("/verifyCaptcha", "Api\CaptchaController@verifyCaptcha");

    //提现
    Route::post('/withdraw', 'Api\AccountController@withdraw');
    Route::post('/withdrawRecord', 'Api\AccountController@withdrawRecord');
    Route::post('/checkBackWithdraw', 'Api\AccountController@checkBackWithdraw');
    Route::post('/getAccountCount', 'Api\AccountController@getCount');
    Route::post("/createWithdrawPassword", "Api\UserDataController@storeWithdrawPassword");
    Route::post("/updateWithdrawPassword", "Api\UserDataController@updateWithdrawPassword");

    //分享
    Route::post('/getShareCount', 'Api\ShareController@getShareCount');
    Route::post('/getPromotionUsers', 'Api\ShareController@getPromotionUsers');
    Route::post('/getPromotionPercentages', 'Api\ShareController@getPromotionPercentages');

    //资金流水
    Route::post('/getFundsDetails', 'Api\FundsDetailController@getFundsDetails');

    //配资相关
    Route::post('/getProducts', 'Api\StockFinanceController@getProducts');
    Route::post('/getStockFinances', 'Api\StockFinanceController@getStockFinances')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/getStockFinance', 'Api\StockFinanceController@getStockFinance')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/stockFinance', 'Api\StockFinanceController@stockFinance')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/stockFinanceOfFree', 'Api\StockFinanceController@stockFinanceOfFree')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/postFinanceCautionMoney', 'Api\StockFinanceController@postFinanceCautionMoney')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");;
    Route::post('/postAddCautionMoney', 'Api\StockFinanceController@postAddCautionMoney')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/modifyAutoSupplyCautionMoney', 'Api\StockFinanceController@modifyAutoSupplyCautionMoney')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/getAllowMaxExtractProfit', 'Api\StockFinanceController@getAllowMaxExtractProfit')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/extractProfit', 'Api\StockFinanceController@extractProfit')->middleware("auth:api");
    Route::post('/settleup', 'Api\StockFinanceController@settleup')->middleware("auth:api")
        ->middleware("App\Http\Middleware\UserForbidden");
    Route::post('/getContract', 'Api\StockFinanceController@getContract');

    //交易相关
    Route::post('/entrustBuy', 'Api\TransactionController@entrustBuy');
    Route::post('/entrustCell', 'Api\TransactionController@entrustCell');
    Route::post('/cancelEntrustBuy', 'Api\TransactionController@cancelEntrustBuy');
    Route::post('/cancelEntrustCell', 'Api\TransactionController@cancelEntrustCell');
    Route::post('/getHoldings', 'Api\TransactionController@getHoldingsList');
    Route::post('/getStockFinanceCount', 'Api\TransactionController@getCount');
    Route::post('/getStockPool', 'Api\TransactionController@getStockPool');
    Route::post('/addStockToPool', 'Api\TransactionController@addStockToPool');
    Route::post('/delStockFromPool', 'Api\TransactionController@delStockFromPool');
    Route::post('/getStocks', 'Api\TransactionController@getStockList');
    Route::post('/getStockInfo', 'Api\TransactionController@getStockInfo');
    Route::post('/getRevocableEntrusts', 'Api\TransactionController@getRevocableEntrustList');
    Route::post('/getEntrusts', 'Api\TransactionController@getEntrustList');
    Route::post('/getEntrustsHistory', 'Api\TransactionController@getEntrustListHistory');
    Route::post('/getMakedeals', 'Api\TransactionController@getMakedealList');
    Route::post('/getMakedealsHistory', 'Api\TransactionController@getMakedealListHistory');
    Route::post('/getStockFinanceDetails', 'Api\TransactionController@getDetails');
    Route::post('/getMaxStockNum', 'Api\TransactionController@getMaxStockNum');

    //微信相关
    Route::any('/wechat', function (Request $request) {
        $wechat = \App\Http\Controllers\Api\WechatController::instance($request);
        if ($wechat) {
            return $wechat->index();
        }
    });
    Route::any('/createWechatMenu', "Api\WechatApiController@createMenu");
    Route::any('/changeCustomerWechatQrcode', "Api\WechatApiController@changeCustomerQrcode");
    Route::any('/redirectOauthPage', 'Api\LoginController@redirectOauthPage');
    Route::any('/loginFromOpenId', 'Api\LoginController@loginFromOpenId');
    Route::post('/bindAccountFromWechat', 'Api\RegisterController@bindAccountFromWechat');
    Route::post("/getWechatBindSms", "Api\RegisterController@sendWechatBindSms")
        ->middleware("App\Http\Middleware\CaptchaCheck");

    Route::get('/craw', 'Api\CrontabController@craw');
});
